#include<stdio.h>
void nu(int a,int b)
{
	if((a+b-1)%7==0)
	{
		printf("\n");
	}
}
int main()
{
	int N=0,day=0,i;
	scanf("%d%d",&N,&day);
	switch (day) 
	{
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
		case 7:
			for(i=0;i<(day-1)*2;i++)
			{
				printf(" ");
			}
			for(i=1;i<=N;i++)
			{
				printf("%2d",i);
				nu(i,day);
			}
			printf("\n");
	}
	return 0;
}

